Shader "Kun URP/Water"
{
    Properties
    {
        _WaterColor ("Water Color", Color) = (1, 1, 1, 1)
        _WaveSpeed ("Wave Speed", Range(-10, 10)) = 0.5
        // _WaveDirection ("Wave Direction", vector) = (1, 1)

        [Space(15)]
        [PowerSlider(3)] _DepthFactor ("Depth Factor", Range(0.001, 20)) = 3.0
        [PowerSlider(3)] _DepthBlendScale ("Depth Blend Scale", Range(0.001, 1)) = 1.0
        [PowerSlider(3)] _DepthBlendPower ("Depth Blend Power", Range(0.001, 10)) = 1.5

        [Header(Caustics)]
        _CausticsMap ("Caustics Map", 2D) = "white" {}
        [HDR] _CausticsColor ("Caustics Color", Color) = (1, 1, 1, 1)

        [Header(Specular)]
        [HDR] _SpecularColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
        [PowerSlider(4)] _Roughness ("Roughness", Range(0.001, 1)) = 0.01

        [Header(Normal)]
        _NormalMap ("Normal Map", 2D) = "black" {}
        [PowerSlider(3)] _NormalScale ("Normal Scale", Range(0, 1)) = 0.15
        _NormalMap2 ("Normal Map2", 2D) = "black" {}
        [PowerSlider(3)] _NormalScale2 ("Normal Scale2", Range(0, 1)) = 0.15

        [Header(Distortion)]
        [PowerSlider(1.5)] _DistortionScale ("Distortion Scale", Range(0, 1)) = 0.1
        _DistortionSpeed ("Distortion Speed", Range(-10, 10)) = 0.5
        _DistortionDirection ("Distortion Direction", Vector) = (1, 1, 0, 0)

        [Header(Reflection)]
        _CubemapTexture ("Reflection Map", Cube) = "black" {}
        _ReflectionColor ("Reflection Color", Color) = (1, 1, 1, 1)
        [PowerSlider(2)] _ReflectionNormalBlend ("Normal Blend", Range(0, 1)) = 0.15
        [PowerSlider(2)] _FresnelPower ("Fresnel Power", Range(1, 100)) = 5
        
        [Header(Foam)]
        _FoamNoiseMap ("Foam Noise Map", 2D) = "black" {}
        _FoamColor ("Foam Color", Color) = (0.5, 0.5, 0.5, 1)
        [PowerSlider(2)] _FoamRange ("Foam Range", Range(0.01, 10)) = 7
        [PowerSlider(2)] _FoamNoisePower ("Noise Power", Range(0.01, 10)) = 3

        [Header(Tesselation)]
        _TessellationEdgeLength ("Tessellation Edge Length", float) = 200
    }

    SubShader
    {
        Tags
        {
             "RenderPipeline" = "UniversalPipeline"
             "RenderType" = "Overlay"
             "Queue" = "Transparent-499"
        }
        
        Pass
        {
            Name "WaterShaderPass"

            // Tags
            // {
            //     "LightMode" = "UniversalForward"
            // }

            HLSLPROGRAM

            #pragma prefer_hlslcc gles
			/////////////////SHADER FEATURES//////////////////
			#pragma shader_feature _REFLECTION_CUBEMAP _REFLECTION_PROBES _REFLECTION_PLANARREFLECTION
			#pragma multi_compile _ USE_STRUCTURED_BUFFER
			#pragma shader_feature _ _STATIC_SHADER
						
			// -------------------------------------
            // Lightweight Pipeline keywords
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
            #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
            #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
            #pragma multi_compile _ _SHADOWS_SOFT

			//--------------------------------------
            // GPU Instancing
            #pragma multi_compile_instancing
            #pragma multi_compile_fog


            #include "../ShaderLibrary/Water/WaterPass.hlsl"

            #pragma vertex WaterTessellationVertex
            #pragma hull WaterPassHull
            #pragma domain WaterPassDomain
            #pragma fragment WaterPassFragment
            
            ENDHLSL
        }

    }
}